<!--
 *@Date: 2022-12-19 14:44:57
 * @LastEditTime: 2023-01-09 17:17:07
 *
 * @Description:
-->
<template>
    <uni-list>
        <view v-for="(item, index) in sjdxDetailFields">
            <uni-list-item :title="sjdxFields[item].zdmc"
                v-if="sjdxFields[item].kjlx === '$select' || sjdxFields[item].kjlx === '$checkbox' || sjdxFields[item].kjlx === '$switch' || sjdxFields[item].kjlx === '$input' || sjdxFields[item].kjlx === 'MyMarkDown' || sjdxFields[item].kjlx === 'jsoneditor'"
                :note="sjdxFields[item].zdkd > 80 ? (sjdxDetail[item + '_mc'] ? sjdxDetail[item + '_mc'] : sjdxDetail[item]) : ''"
                :rightText="sjdxFields[item].zdkd <= 80 ? (sjdxDetail[item + '_mc'] ? sjdxDetail[item + '_mc'] : sjdxDetail[item]) : ''">
            </uni-list-item>
            <uni-list-item :title="sjdxFields[item].zdmc"
                :note="sjdxFields[item].zdkd > 80 ? dayjs(sjdxDetail[item], 'YYYYMMDDHHmmss').format('YYYY-MM-DD HH:mm:ss') : ''"
                :rightText="sjdxFields[item].zdkd <= 80 ? dayjs(sjdxDetail[item], 'YYYYMMDDHHmmss').format('YYYY-MM-DD HH:mm:ss') : ''"
                v-else-if="sjdxFields[item].kjlx === 'ElDatePicker'">
            </uni-list-item>
            <uni-list-item :title="sjdxFields[item].zdmc" v-else-if="sjdxFields[item].kjlx === 'MyImage'">
                <template v-slot:footer>
                    <data-image v-model="sjdxDetail[item]" />
                </template>
            </uni-list-item>
            <uni-section v-else-if="sjdxFields[item].kjlx === 'MyGroup'" :title="sjdxFields[item].zdmc"
                type="line"></uni-section>
        </view>
    </uni-list>
</template>
<script setup lang="ts">
import { onLoad } from '@dcloudio/uni-app';
import { ref } from 'vue';
import dayjs from 'dayjs';
import SjdxModelImp from '../model/SjdxModelImp';

const sjdxModelImp = new SjdxModelImp()
const sjdxDetail = ref({})
const sjdxFields = ref({})
const sjdxDetailFields = ref([] as any)
onLoad(({ dm, id, title }: any) => {
    uni.setNavigationBarTitle({
        title: title
    });
    sjdxModelImp.initSjdx(dm).then((result: any) => {
        sjdxFields.value = sjdxModelImp.getSjdxFields()
        sjdxDetailFields.value = sjdxModelImp.getSjdxDetailFields()
        console.log(sjdxDetailFields.value)
        sjdxModelImp.getSjdxList(
            result.sys.authCode, undefined, { id: id }, "").then(res => {
                sjdxDetail.value = res.list[0]
            })
    })
})
</script>
